package xiangmu.schoolpaper.controller.student;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xiangmu.schoolpaper.pojo.DTO.StudentDetailScoreDTO;
import xiangmu.schoolpaper.pojo.VO.StudentDetailScoreVO;
import xiangmu.schoolpaper.pojo.VO.StudentOneScoreVO;
import xiangmu.schoolpaper.result.Result;
import xiangmu.schoolpaper.service.impl.StudentDataListServiceImpl;

import java.util.List;

@RequestMapping("/student")
@RestController
@Slf4j
@Tag(name = "学生数据列表接口")
public class StudentDataListController {
    @Autowired
    private StudentDataListServiceImpl studentDataListServiceImpl;

    @GetMapping("/paper/download")
    @Operation(summary = "下载论文接口")
    private Result download(Integer paperId) {
        log.info("根据学生的id返回对应论文的URL");
        String url = studentDataListServiceImpl.download(paperId);
        return Result.success(url);
    }

    @GetMapping("/getOneScore")
    @Operation(summary = "获取学生论文的一级指标得分")
    public Result getOneScore(Integer studentId) {
        log.info("根据学生的id返回学生论文的一级指标得分，学生为：{}", studentId);
        List<StudentOneScoreVO> studentOneScoreVO = studentDataListServiceImpl.getOneScore(studentId);
        if (studentOneScoreVO != null && studentOneScoreVO.size() > 0) {
            return Result.success(studentOneScoreVO);
        }
        return Result.error("该学生的论文得分为空，请检查该学生是否上传了论文");
    }

        @GetMapping("/getDetailScore")
    @Operation(summary = "获取学生论文的二级指标得分")
    public Result getDetailScore(@RequestBody StudentDetailScoreDTO s) {
        log.info("根据学生的id返回学生论文的二级指标得分，学生为：{}", s);
        List<StudentDetailScoreVO> studentDetailScoreVO = studentDataListServiceImpl.getDetailScore(s);
        return Result.success(studentDetailScoreVO);
    }

}
